package cn.core.tool.service;

import cn.core.tool.mapper.CoreMapper;
import com.baomidou.dynamic.datasource.annotation.DS;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Map;

/**
 * 服务
 */
@Log4j2
@Service
public class CoreService {

  @Resource
  private CoreMapper coreMapper;

  /**
   * 动态执行sql
   */
  @DS("#dsName")
  public Object execSql(String dsName, String sqlStr, Map<String, Object> param) throws Exception {
    try {
      return coreMapper.execSql(sqlStr, param);
    } catch (Exception e) {
      if (log.isDebugEnabled()) {
        log.error(e.getMessage(), e);
      }
      throw e;
    }
  }

}
